﻿namespace EyeOpen.IO.Test
{
	using System.IO;
	using Microsoft.VisualStudio.TestTools.UnitTesting;

	[TestClass]
	public abstract class DirectorySearchTest
	{
		private readonly ILogger logger = new TestLogger();

		private readonly IDirectoryInfo directoryInfo;

		protected DirectorySearchTest()
		{
			directoryInfo = GetDirectoryInfo();
		}

		[TestMethod]
		public void SearchFileThatExist()
		{
			var file =
				new DirectorySearch()
					.Search(directoryInfo, DirectoryKnownValues.FileName, logger);

			var expectedPath =
				Path.Combine(directoryInfo.FullName, DirectoryKnownValues.Folder, DirectoryKnownValues.FileName);

			Assert.AreEqual(file.FullName, expectedPath);
		}

		[TestMethod]
		public void SearchFileThatNotExist()
		{
			var file =
				new DirectorySearch()
					.Search(directoryInfo, "notexists.txt", logger);

			Assert.IsNull(file);
		}

		protected abstract IDirectoryInfo GetDirectoryInfo();
	}
}